//
//  UIViewController+YYRPopupController.m
//  SISSAPP
//
//  Created by 袁应荣 on 2019/7/8.
//  Copyright © 2019 优房网. All rights reserved.
//

#import "UIViewController+YYRPopupController.h"
#import "YYRPopupController.h"

@implementation UIViewController (YYRPopupController)

- (void)popupAlertWithTitle:(NSString *)title message:(NSString *)message leftConfirmTitle:(NSString *)leftConfirmTitle rightConfirmTitle:(NSString *)rightConfirmTitle selectLeftBlock:(void (^)())leftBlock selectRightBlock:(void (^)())rightBlock {
    YYRPopupController *popupController = [YYRPopupController alertWithTitle:title message:message];
    YYRPopupAction *leftAction = [YYRPopupAction actionWithTitle:leftConfirmTitle style:YYRPopupActionStyleDefault handler:^{
        [self dismissViewControllerAnimated:YES completion:nil];
        if (leftBlock) leftBlock();
    }];
    YYRPopupAction *rightAction = [YYRPopupAction actionWithTitle:rightConfirmTitle style:YYRPopupActionStyleDefault handler:^{
        [self dismissViewControllerAnimated:YES completion:nil];
        if (rightBlock) rightBlock();
    }];
    [popupController addActions:@[leftAction, rightAction]];
    
    [self presentViewController:popupController animated:YES completion:nil];
}

@end
